JavaScript: For Beginners by Francis John Thottungal

JavaScript: For Beginners by Francis John Thottungal
Author: Francis John Thottungal [Thottungal, Francis John]
Language: eng
Format: epub, azw3, pdf
Published: 2017-05-08

Chapter 13. Date


A date object in JavaScript is created with new Date().

The properties of the date object are as follows:

Constructor - gives the function that created the date object.

Prototype - allows properties to be added to objects.

When a date object is created with new Date() without anything in the brackets then the date object is set the current date and time on the system.

Milliseconds: Placing 10000 within the brackets creates a date that represents ten seconds past midnight on 1/1/70.

Datestring: a string representation of the date, in the format accepted by the Date.parse() method will be taken as the value of the object.

Arguments: The date object can take several other arguments inside the bracket such as:

year: Integer value representing the year in full format. Ex: 2017

month: Integer value representing the month, beginning with 0 for January.

date: Integer value representing the day of the month.

hour: Integer value representing the hour of the day in 24-hour format.

minute: Integer value representing the minute segment of a time reading.

second: Integer value representing the second segment of a time reading.

millisecond: Integer value representing the millisecond segment of a time reading.